package com.fanketly.funacg2.data.db

import androidx.paging.PagingSource
import androidx.room.*
import com.fanketly.funacg2.data.entity.WorkEntity
import kotlinx.coroutines.flow.Flow

@Dao
interface WorkDao {
    @Query("select * from work")
    fun getAll(): PagingSource<Int,WorkEntity>

//    @Query("select * from diary where year=:year and month=:month and dayOfMonth=:dayOfMonth")
//    fun queryByDate(year: Int, month: Int, dayOfMonth: Int): Flow<DiaryModel?>

//    @Query("select * from diary where year=:year ")
//    fun queryByYear(year: Int): Flow<List<DiaryModel>>

    @Insert(onConflict = OnConflictStrategy.IGNORE)
    suspend fun insert(worksEntity: WorkEntity): Long

//
//    @Query("delete from diary")
//    suspend fun deleteAll()

    //    @Update
//    suspend fun update(diaryModels: List<DiaryModel>)
    @Query("delete from work where id=:id")
    suspend fun delete(id: Int)

    @Query("select * from work where id=:id")
    suspend fun isFavourite(id: Int): WorkEntity?

}
